package com.param_validate_demo.controller;


import com.param_validate_demo.groups.Insert;
import com.param_validate_demo.groups.Query;
import com.param_validate_demo.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {

    @PostMapping("/add")
    @ResponseBody
    public String addUser(@Validated(Insert.class) @RequestBody User user) {
        return "新增成功";
    }

    @PostMapping("/query")
    @ResponseBody
    public String query(@Validated(Query.class) @RequestBody User user) {
        return "查询成功";
    }
}
